package com.mexico.inloancash.utils;

import android.content.Context;
import android.content.Intent;
import android.os.Build;
import android.text.TextPaint;
import android.text.style.ClickableSpan;
import android.view.View;

import androidx.annotation.RequiresApi;

import com.mexico.inloancash.R;
import com.mexico.inloancash.activity.IndiaWeb_ViewActivity;


public class India_Customized_ClickableSpan extends ClickableSpan {

    String text;
    private Context context;

    public India_Customized_ClickableSpan(String text, Context context) {
        super();
        this.text = text;
        this.context = context;
    }

    @RequiresApi(api = Build.VERSION_CODES.M)
    @Override
    public void updateDrawState(TextPaint ds) {
//	    ds.setColor(ds.linkColor);
        ds.setColor(context.getColor(R.color.click_bg_color));
//	    ds.setUnderlineText(false);
    }


    @Override
    public void onClick(View widget) {
        //widget.setBackgroundColor(Color.TRANSPARENT);
        //Toast.makeText(context, text, Toast.LENGTH_SHORT).show();
        //跳转第一个链接
        Intent web = new Intent(context, IndiaWeb_ViewActivity.class);
        if (text.trim().equals("Términos de servicio")) {
            //服务条款
            web.putExtra("webUrl", "https://admininwb.holymondy.com/appapi/login/agreement");
            web.putExtra("titleName","Privacy Policy");
            //context.startActivity(web);
        } else {
            //隐私政策
            //跳转第二个链接
            web.putExtra("webUrl", "https://admininwb.holymondy.com/appapi/login/agreement");
            web.putExtra("titleName","Privacy Policy");
            //context.startActivity(web);
        }
    }
}
